package com.woniuxy;

import java.io.Serializable;
import java.util.*;

/**
 * @author 作者
 * @create 2025-09-12 9:40
 */
class Aaa implements Comparable<Aaa>{
    int a;

    public Aaa(int a) {
        this.a = a;
    }



    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;
        Aaa aaa = (Aaa) o;
        return a == aaa.a;
    }

    @Override
    public int hashCode() {
        return 1;
    }

    @Override
    public int compareTo(Aaa o) {
        return this.a - o.a;
    }
}


public class Test01 {
    public static void main(String[] args) {

    }

    private static void test07() {
        TreeSet<Aaa> strs = new TreeSet<>();
        strs.add(new Aaa(1));
        strs.add(new Aaa(2));
        System.out.println(strs);
    }

    private static void test06() {
        TreeSet<String> strs = new TreeSet<>();
        strs.add("aaa");
        strs.add("bbb");
        strs.add("ccc");
        strs.add("ddd");
        strs.add("eee");
        System.out.println(strs);
    }

    private static void test05() {
        LinkedHashSet<String> strs=new LinkedHashSet<>();
        strs.add("aaa");
        strs.add("bbb");
        strs.add("ccc");
        strs.add("ddd");
        strs.add("aaa");
        strs.add("bbb");
        strs.add("ccc");
        strs.add("ddd");
        System.out.println(strs);
    }

    private static void test04() {
        //        HashSet<Integer> set = new HashSet<>();
//        for (int i = 1; i <= 12; i++) {
//            set.add(i);
//        }
        //初始16，满了12扩容
//        set.add(13);
//        set.add(14);


        HashSet<Aaa> set = new HashSet<>();
        for(int i=1;i<=7;i++){
            set.add(new Aaa(i));
        }
        set.add(new Aaa(8));
        set.add(new Aaa(9));
        set.add(new Aaa(10));
        set.add(new Aaa(11));
        set.add(new Aaa(12));
        set.add(new Aaa(13));
    }

    private static void test03() {
        HashSet<String> strs=new HashSet<>();
        strs.add("aaa");
        strs.add("bbb");
        strs.add("ccc");
        strs.add("Aa");
        strs.add("BB");
        System.out.println(strs);
        System.out.println("aaa".hashCode());
        System.out.println("Aa".hashCode());
        System.out.println("BB".hashCode());
    }

    private static void test02() {
        HashSet<Student> students = new HashSet<>();
        students.add(new Student(1,"zs",11));
        students.add(new Student(2,"ls",12));
        students.add(new Student(1,"zs",11));
        System.out.println(students);

        Student s1=new Student(1,"zs",11);
        Student s2=new Student(1,"zs",11);
        System.out.println(s1.hashCode());
        System.out.println(s2.hashCode());
        System.out.println(s1.equals(s2));
        System.out.println(s1.toString());
        System.out.println(Integer.toHexString(s1.hashCode()));

        String str1 = new String("aaa");
        String str2 = new String("aaa");
        System.out.println(str1.hashCode());
        System.out.println(str2.hashCode());

        byte b=127;
        System.out.println(b&0xff);
        b=-128;
        System.out.println(b&0xff);

        System.out.println("Aa".hashCode());
        System.out.println("BB".hashCode());
    }

    private static void test01() {
        LinkedList<String> list = new LinkedList<>();
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");
        list.add("ddd");
        list.add("eee");
        for (String str : list) {
            System.out.println(str);
        }
    }
}
